﻿<Page
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:SoCalNews"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:UI="using:Microsoft.Advertising.WinRT.UI"
    x:Class="SoCalNews.MainPage"
    mc:Ignorable="d">
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <!-- Title -->
        <TextBlock x:Name="TitleText" Text="{Binding Title}"
                   VerticalAlignment="Center" FontSize="48" Margin="110,0,110,0"/>
        <Button x:Name="Next"  Content="Next" Height="100" Width="100" HorizontalAlignment="Right" Click="Button_Click_1"/>
        <Button x:Name="Previous"  Content="Previous" Height="100" Width="100" HorizontalAlignment="Left" Click="Button_Click_2"/>
        <!-- Content -->
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="2*" MinWidth="320" />
                <ColumnDefinition Width="3*" />
            </Grid.ColumnDefinitions>
            <!-- Left column -->
            <!-- The default value of Grid.Column is 0, so we do not need to set it   
                 to make the ListView show up in the first column. -->
            <ListView x:Name="ItemListView"  
          ItemsSource="{Binding Items}"
          Margin="60,0,0,10" SelectionChanged="ItemListView_SelectionChanged">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <TextBlock Text="{Binding Title}"  
                           FontSize="24" Margin="5,0,0,0" TextWrapping="Wrap" />
                            <TextBlock Text="{Binding Path=PubDate, 
                                       Converter={StaticResource dateConverter}}" 
                                       FontSize="16" Margin="15,0,0,0"/>
                            <TextBlock Text="{Binding Path=Category}" 
                                       FontSize="16" Margin="15,0,0,0"/>
                            <TextBlock Text="{Binding Path=Content}" TextWrapping="Wrap" 
                                       FontSize="16" Margin="15,0,0,0"/>
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
            <!-- Right column -->
            <!-- We use a Grid here instead of a StackPanel so that the WebView sizes correctly. -->
            <Grid DataContext="{Binding ElementName=ItemListView, Path=SelectedItem}"
                  Grid.Column="1" Margin="25,0,0,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <TextBlock x:Name="PostTitleText" Text="{Binding Title}" FontSize="24" />
                <Grid Grid.Row="1" Grid.Column="1" Margin="0 0 10 0">
                    <WebView x:Name="ContentView" Grid.Row="1" Margin="0,5,20,62" Visibility="Collapsed"/>
                    <Rectangle x:Name="BlockingRect" />
                    <ProgressRing x:Name="ProgressRing1" Height="50" Width="50"/>
                    <UI:AdControl 
                ApplicationId="3e798207-e438-4660-b671-4b3604f5b579" 
                AdUnitId="112032" 
                HorizontalAlignment="right" 
                Height="60" 
                Margin="0,10,10,0" 
                VerticalAlignment="bottom" 
                Width="292"
                    Grid.Column="1"
                />
                </Grid>
                
            </Grid>
        </Grid>
    </Grid>
</Page>